package sql_age;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class RedTest extends Reducer<IntWritable, IntWritable, result, NullWritable> {
    @Override
    protected void reduce(IntWritable key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        int count = 0;
        for (IntWritable iw : values) {
            count += iw.get();
        }
        result sr = new result();
        sr.setAge(key.get());
        sr.setCount(count);
        context.write(sr, NullWritable.get());
    }
}
